﻿using System.Web.UI.WebControls;
using Controller;

namespace AppCommon
{
    /// <summary>
    /// Summary description for BindDatatoDDL
    /// </summary>
    public class BindDatatoDDL
    {
        public BindDatatoDDL()
        {
		
        }

        public static void BindCategory(DropDownList dropDownList)
        {
            var controller = new CategoryController();
            dropDownList.DataSource = controller.GetListCategory();
            dropDownList.DataTextField = "Name";
            dropDownList.DataValueField = "Id";
            dropDownList.DataBind();

            //var item = new ListItem {Text = " -- Chọn --", Value = "0"};
            //dropDownList.Items.Insert(0, item);
        }

        public static void BindUserRole(DropDownList dropDownList)
        {
            var controller = new UserRoleController();
            dropDownList.DataSource = controller.GetListUserRole();
            dropDownList.DataTextField = "RoleName";
            dropDownList.DataValueField = "Id";
            dropDownList.DataBind();

            //var item = new ListItem {Text = " -- Chọn --", Value = "0"};
            //dropDownList.Items.Insert(0, item);
        }
    }
}